package top.kaoshanji.r7ch14b;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import top.kaoshanji.r7ch14b.mapper.ForumMapper;
import top.kaoshanji.r7ch14b.domain.Forum;

/**
 * 代码清单-r7ch14b-481页a：使用映射接口
 * @author kaoshanji
 * ^_^
 * create time 2025/5/12 14:39
 */
@Repository
public class ForumMybatisTemplateDao {

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

    public Forum getForum(int forumId) {
        ForumMapper mapper = sqlSessionTemplate.getMapper(ForumMapper.class);
        return mapper.getForum(forumId);
    }

    public int getForumNum() {
        ForumMapper mapper = sqlSessionTemplate.getMapper(ForumMapper.class);
        return mapper.getForumNum();
    }

}
